package com.fangcang.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 *  RedisTemplate配置
 * @author fangcang
 * @date 2019年1月25日
 * @description
 */
@Configuration
public class RestTemplateConfiguration {

	
	@Bean
    public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
        return new RestTemplate(factory);
    }
 
    @Bean
    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        //
        factory.setReadTimeout(5000);//ms
        //连接超时参数(ms)，默认-1，永不超时
        factory.setConnectTimeout(15000);
        return factory;
    }
}
